extends Node2D

const SPEED = 60
var direciton = 1
@onready var ray_cast_right = $RayCastRight
@onready var ray_cast_left  = $RayCastLeft
@onready var animated_sprite  = $AnimatedSprite2D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if ray_cast_right.is_colliding():
		direciton = -1
		animated_sprite.flip_h = true # 水平翻转
	if ray_cast_left.is_colliding():
		direciton = 1
		animated_sprite.flip_h = false
	
	position.x += direciton * SPEED * delta
	
